#include <iostream>
#include <string>
#include <vector>
using namespace std;

int g_Cnt = 0;
// dfs 深度优先，走不通时return 
void BlackCnt(vector<vector<char>>& v, int row, int col){
    if(row<0 || row>=v.size() || col<0 || col>=v[0].size() || v[row][col]=='#')   
        return ;   // 超出范围 或者 是红色时回退
    ++g_Cnt;
    v[row][col] = '#';   //标记走过的，不能再走
    BlackCnt(v, row+1, col);
    BlackCnt(v, row-1, col);
    BlackCnt(v, row, col+1);
    BlackCnt(v, row, col-1);
}

int main()
{
    int m, n;
    while(cin >> m >> n){
        vector<vector<char>> plane(m, vector<char>(n));
        int row, col;
        for(int i = 0; i < m; ++i){
            for(int j = 0; j < n; ++j){
                cin >> plane[i][j];
                if(plane[i][j] == '@')
                    row = i, col = j;             
            }
        }
        BlackCnt(plane, row, col);
        cout << g_Cnt << endl;
        g_Cnt = 0;    // 清 0
    }
    return 0;
}
